<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ page import="java.util.*"%>
<%@ include file="index.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="favicon.ico">
<link rel="Shortcut Icon" href="favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css"
	href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css"
	href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css"
	href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css"
	href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css"
	href="static/h-ui.admin/css/style.css" />

<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<!--/meta 作为公共模版分离出去-->

<!-- <title>新增文章 - 资讯管理 - H-ui.admin v3.0</title>
<meta name="keywords" content="耶回收">
<meta name="description" content="耶回收"> -->
</head>
<body>
	<section class="Hui-article-box">
	<form class="form form-horizontal" id="form-article-add" action="<%=basePath%>perAdd" method="post">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span
				class="c-red">*</span>真实姓名：</label>
			<div class="formControls col-xs-8 col-sm-4">
				<input type="text" class="input-text" placeholder="请输入真实姓名"
					id="nickname" name="nickname" data-msg-required="姓名不能为空" data-rule-required="true">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span
				class="c-red">*</span>用户名：</label>
			<div class="formControls col-xs-8 col-sm-4">
				<input type="text" class="input-text" placeholder="请输入用户名"
					id="uname" name="uname" data-msg-required="用户名不能为空" data-rule-required="true" onchange="checkname()">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span
				class="c-red">*</span>密码：</label>
			<div class="formControls col-xs-8 col-sm-4">
				<input type="text" class="input-text" placeholder="请输入密码"
					id="upassword" name="upassword" data-msg-required="密码不能为空" data-rule-required="true">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span
				class="c-red">*</span>手机：</label>
			<div class="formControls col-xs-8 col-sm-4">
				<input type="text" class="input-text" placeholder="请输入手机"
					id="uphone" name="uphone" data-msg-required="手机不能为空" data-rule-required="true" onblur="phone()" maxlength="11">
			</div>
		</div>

		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">性别：</label>
			<div class="formControls col-xs-8 col-sm-4">
				<input type="radio" class="usex" name="usex" value="1" checked="checked">男
				<input type="radio" class="usex" name="usex" value="0">女
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2"><span
				class="c-red">*</span>权限：</label>
			<div class="formControls col-xs-8 col-sm-6">
				<input type="checkbox" value="1001" name="perid" >商品管理<br>
				<input type="checkbox" value="1002" name="perid" >查询商品<br>
				<input type="checkbox" value="1003" name="perid" >操作订单<br>
				<input type="checkbox" value="1004" name="perid" >查询订单<br>
				<input type="checkbox" value="1005" name="perid" >管理用户<br>
				<input type="checkbox" value="1006" name="perid" >查询用户<br>
				<input type="checkbox" value="1007" name="perid" >操作管理员
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
				<button class="btn btn-secondary radius"
					type="submit">
					<i class="Hui-iconfont">&#xe632;</i> 确认添加
				</button>
			</div>
		</div>
	</form>
	</section>
<script type="text/javascript" src="<%=basePath%>lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript">
		//表单验证
		$(function(){
			 $("#form-article-add").validate( {
				         //做完表单验证后的  ajax后台数据验证 如果不满足条件 则禁止表单的提交
					   	 submitHandler: function(form){
						
					     return phone()&&checkname();
					     //发出ajax请求 根据回调函数的返回值 来判断checkBackitemExsit()的返回值；
					    
					    }
			 
				 
			 });
			 
		 });

		//手机校验
		function phone(){
			var phone = $("#uphone").val();
			if (phone.length == 0) {
				layer.msg("请输入有效的手机号码，需是11位！",{icon: 2,time:2000});
				return false;
			}
			if (phone.length != 11) {
				layer.msg("请输入有效的手机号码，需是11位！",{icon: 2,time:2000});
				return false;
			}

			var myreg = /^(1\d{10})$/;
			if (!myreg.test(phone)) {
				layer.msg("请输入有效的手机号码！",{icon: 2,time:2000});
				return false;
			}
			
			return true;
		};

		//判断用户名是否存在
		function checkname(){
			var fale = false;
			var name = $("#uname").val();
			$.ajaxSettings.async = false;
			$.post("checkname",{uname:name},function(data){
				if(data.success){
					fale=true;
				}else{
					layer.msg(data.msg,{icon: 2,time:2000});
				}
			},"json");
			$.ajaxSettings.async = true;
			return fale;
		}
</script>
</body>
</html>